$('.right-titleicon').on("click",function(e){
	projectVM.showMenulist()
})

projectVM = new Vue({
	el: "#content",
	components:{
		personselect,
		processlog
	},
	data: {
		trainingfileList:[],
		fileIdstraining:'',
		id:'',
		isSingle:true,
		menuList:[
			{name:'交班',path:'handOver.html'},{name:'接班',path:'carryOn.html'},{name:'列表',path:'index.html'},
		],
		nowDate:'',
		userInfo:'',
		training:[],
		fileList:[],
		chatList:[],
		staffType:'0',
		trainingDrill:[],
		changeValue:'',
		checked:[],
		showSubmit:false,
		onStatus:'',
		result:'',
		memberText:'',
		showMenu:false,
		showMorebtn:false,
		staffSpeak:'',
		advance:'',
		showAdd:false,
		show_popup:false,
		list:[{content:'XXX信用XXXX钥匙',status:1,user:'[IP123456]张三2021-6-20'},
		{content:'XXX信用XXXX钥匙',status:2,user:'[IP123456]张三2021-6-20'},
		{content:'XXX信用XXXX钥匙',status:3,user:'[IP123456]张三2021-6-20'}
	]
	},
	created: function() {
		mui.init()
	   var obj = JSON.parse(localStorage.getItem('todoWork')).obj
	   // console.log(localStorage.getItem('todoWork'))
		this.id = obj.regularWorkTaskConfigId
		if(obj.workId != null){
			this.workId = obj.workId
			this.getDetailbyworkId()
		}
		else{
			this.getDetail()
		}
		this.userInfo = JSON.parse(localStorage.getItem("neiosUser"))
		this.getFileids()
		
		
	},
	methods: {
		//保存文件
		saveFile(){
			
		},
		// 上傳
			upload(e) {
				let that = this
				mui.neiosCommon.doUploads(function(ret) {
					if ("0" == ret.code) {
						console.log("成功：" + JSON.stringify(ret))
						that.saveFile()	
								
					} else {
						mui.toast('文件上传失败');
					}
				}, function(err) {
					mui.toast('文件上传失败');
				})
			},
			// 删除文件
			delDown(data) {
				let myFileIds = this.fileIds.split(',')
				myFileIds.splice(myFileIds.findIndex(item => item.fileId === data.fileId), 1)
				this.fileIds = myFileIds.join(',')
				console.log(this.fileIds)
				this.getFileds()
			},
			// 下载
			downLoad(data) {
				let url = "/app/common/downloadFile";
				let param = {};
				param.fileId = data.fileId;
				mui.neiosCommon.downLoadFile(param, function(ret) {
					mui.plusReady(function() {
						plus.nativeUI.closeWaiting();
					})
					//调用存储
					var callbackID = plus.bridge.callbackId(function(ret) {
						mui.toast(ret[0])
					}, function(err) {
						mui.toast('文件下载失败')
					});
					plus.bridge.execSync("FileHelper", "doFileSave", [callbackID, ret, data.fileName,
						"Argus3", "Argus4"
					])
				}, function(err) {
					mui.plusReady(function() {
						plus.nativeUI.closeWaiting();
					})
					mui.toast('文件下载失败')
				});
				
		},
		//通过workId查询
		getDetailbyworkId(){
			var that = this
			let param = {
				workId:this.workId
			}
			mui.neiosRequst.httpRequst('/app/tranEducation/getTrainingByWorkId', param,
				function(data) {
					
					that.trainingDrill = data.data
					that.trainingDrill.hostStaffCode = that.userInfo.userId
					that.trainingDrill.hostStaffName = that.userInfo.name
					that.trainingDrill.hostStaffNameCode ='['+that.userInfo.userId+']' + that.userInfo.name
					that.training = data.data.training
				},
				function() {
					console.log("查询失败!");
				}
			);
		},
		//保存
		save(){
			
			if(this.$refs.personselect.personids != ''){
				this.training.reviewStaffCode = this.$refs.personselect.personids
				this.training.reviewStaffName =this.$refs.personselect.person.split(']')[1]
				this.trainingDrill.training.reviewStaffCode = this.$refs.personselect.personids
				this.trainingDrill.training.reviewStaffName =this.$refs.personselect.person.split(']')[1]
			}
			this.training.dataSource = 'NEIOS_APP'+localStorage.getItem("currVersion")
			let param = {
				trainingAttachList:this.fileList,
				training: this.training,
				trainingDrill:this.trainingDrill,
				currentUser:this.userInfo
			}
	mui.neiosRequst.httpRequst('/app/tranEducation/saveTraining', param,
		function(data) {
			mui.toast('操作成功')
			setTimeout(function() {
				mui.back()
				let page = plus.webview.getWebviewById("../sitOperation/terminalwork/terminalwork.html");
				let pageId = plus.webview.getWebviewById(page.id); 
				let param = {} 
				param.isRefresh = true
				mui.fire(pageId, 'isRefresh', param);
			}, 500);
		},
		function() {
			console.log("查询失败!");
		}
	);
		},
	
	//提交
	submit(){
			
			if(this.$refs.personselect.personids != ''){
				mui.toast('请选择审核人')
				return
				}
				this.training.reviewStaffCode = this.$refs.personselect.personids
				this.training.reviewStaffName =this.$refs.personselect.person.split(']')[1]
				this.trainingDrill.training.reviewStaffCode = this.$refs.personselect.personids
				this.trainingDrill.training.reviewStaffName =this.$refs.personselect.person.split(']')[1]
			
			this.training.dataSource = 'NEIOS_APP'+localStorage.getItem("currVersion")
			let param = {
				trainingAttachList:this.fileList,
				training: this.training,
				trainingDrill:this.trainingDrill,
				workDesc:"安全活动方案指定参数",
				workType:'0301',
				currentUser:this.userInfo
				
			}
		mui.neiosRequst.httpRequst('/app/tranEducation/submitTraining', param,
		function(data) {
			mui.toast('操作成功')
			setTimeout(function() {
				mui.back()
				let page = plus.webview.getWebviewById("../sitOperation/terminalwork/terminalwork.html");
				let pageId = plus.webview.getWebviewById(page.id); 
				let param = {} 
				param.isRefresh = true
				mui.fire(pageId, 'isRefresh', param);
			}, 500);
		},
		function() {
			console.log("查询失败!");
		}
	 );
	},	
			//获取文件id
			getFileids(){
				var that = this
				var param = {
				trainingDrillId:this.trainingDrill.trainingDrillId,
				fileUserType:'base_info'
			}
				mui.neiosRequst.httpRequst('/app/tranEducation/getTrainingFileIds', param,
				function(data) {
					if(data.data != ''){
						that.getFileList(data.data)
					}	
				},
				function() {
					console.log("查询失败!");
				}
			);
			},
			//获取文件信息
			getFileList(e){
				var param = {
					fileIds:e
				}
				var that = this
				mui.neiosRequst.httpRequst('/app/common/getFileList', param,
				function(data) {
					that.fileList = data.data
				},
				function() {
					console.log("查询失败!");
				}
			);
			},
		//返回上一页
		goBack(){
			mui.back()
		},
		//刷新
		refresh(){
			this.getChat()
			this.getTrainingStaff()
		},
		//获取当前时间
		getDate(){
			var date =new Date()
			var year = date.getFullYear()
			var month =date.getMonth()
			var day = date.getDate()
			var hour = date.getHours()
			var min = date.getMinutes()
			
			if(month.toString().length < 2){
				month = '0'+ month
			}
			if(day.toString().length < 2){
				day = '0'+ day
			}
			if(hour.toString().length < 2){
				hour = '0'+ hour
			}
			if(min.toString().length < 2){
				min = '0'+ min
			}
			this.nowDate = year + '-' + month + '-' + day +' '+hour+':'+min
		},

		//获取详情
		getDetail(){
			var that = this
			let param = {
				trainingDrillId:this.id
			}
			console.log(this.id)
			mui.neiosRequst.httpRequst('/app/tranEducation/getTrainingDrillById', param,
				function(data) {
					console.log(JSON.stringify(data.data))
					that.trainingDrill = data.data
				},
				function() {
					console.log("查询失败!");
				}
			);
		},
		//参与
		join(){
			var btnArray= ['否','是']
			mui.confirm('是否确定参与?','确认',btnArray,function(e){
				
			})
		},
		//返回上一页
		goBack(){
			mui.back()
		},

		//阻止事件冒泡
		clickStop(){

		},
		
		navTo(e){
			mui.openWindow({
					url: e,
					id: e,
			});
			}
	},

	})
	
